<template>
  <div>
    <div class="momentContainer" v-for="item in momentList" :key="item.id" @click="toDetail(item.id)">
      <h4 class="title">{{item.title}}</h4>
      <div class="content" v-html="item.content"></div>
      <span class="createTime">发布帖子{{passTime(item.createAt)}}</span>
    </div>
  </div>
</template>

<script>
import passTime from '../utils/passTime'
export default {
  props: {
    momentList: {
      type: Array
    }
  },
  methods: {
    toDetail (id) {
      this.$router.push(`/detail/${id}`)
    },
    passTime
  }
}
</script>

<style scoped lang="less">
.momentContainer {
  border-bottom: 1px solid #eee;
  :hover {
    cursor: pointer;
  }
  .title {
    :hover {
      color: #5a9cf8;
    }
    font-size: 18px;
    font-weight: 500;
    line-height: 24px;
    white-space: normal;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 1;
    overflow: hidden;
  }
  display: flex;
  flex-direction: column;
  padding: 10px 20px;
  .content {
    margin-top: 10px;
    margin-bottom: 20px;
    font-size: 14px;
    font-weight: 400;
    color: #555666;
    overflow: hidden;
    white-space: pre-wrap;
    word-break: break-word;
    display: -webkit-box;
    -webkit-box-orient: vertical;
    -webkit-line-clamp: 2;
  }
  .createTime {
    font-size: 14px;
    line-height: 20px;
    color: #555666;
  }
}

</style>
